<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Notifications\Notifiable;
use Watson\Validating\ValidatingTrait;
class Exam extends Model
{
    use  Notifiable;
    use ValidatingTrait;
    use SoftDeletes;
    protected $table = 'exams';
    //
    protected $fillable = [
        'e_name', 'e_code','e_codes','c_id','place','begin','end','is_required','persons','semester_id'
        ,'serial_number','is_make_up'
    ];
    protected $rules = [
        'e_name' => 'required|max:20',
    ];
    public function Semesters()
    {
        return $this->hasOne('App\Models\Semester','id','semester_id');
    }


    protected $validationMessages = [
        'e_name.required' => '考试名称必填',
        'e_name.max' => '考试名称长度不得超过20个字符',
        'e_name.unique' => '该考试已经被注册过了'
    ];
}
